function [chrom,obj]=updates(weight,chrom,obj,newpoint,Z_new,Z,Z_max)
weight(weight==0)=0.00001;
gui = Z_max - Z;
if length(Z_new) == 4
    parta= [Z_new(1)-Z(2) Z_new(2)-Z(1) Z_new(3)-Z(4) Z_new(4)-Z(3)]./gui;
    partb = [weight(1)*parta(1) weight(1)*parta(2) weight(2)*parta(3) weight(2)*parta(4)];
    newobj = compare(partb,2);

    partc= [obj(1)-Z(2) obj(2)-Z(1) obj(3)-Z(4) obj(4)-Z(3)]./gui;
    partd = [weight(1)*partc(1) weight(1)*partc(2) weight(2)*partc(3) weight(2)*partc(4)];
    oldobj = compare(partd,2);

    compare1 = [newobj,oldobj];
    result = compare(compare1,1);
    if result == newobj
        chrom=newpoint;
        obj=Z_new;
    end
elseif length(Z_new) == 6
    parta= [Z_new(1)-Z(2) Z_new(2)-Z(1) Z_new(3)-Z(4) Z_new(4)-Z(3) Z_new(5)-Z(6) Z_new(6)-Z(5)]./gui;
    partb = [weight(1)*parta(1) weight(1)*parta(2) weight(2)*parta(3) weight(2)*parta(4) weight(3)*parta(5) weight(3)*parta(6)];
    newobj1 = compare(partb(1:4),2);                       
    newobj = compare([newobj1,partb(5:6)],2);              
    
    partc= [obj(1)-Z(2) obj(2)-Z(1) obj(3)-Z(4) obj(4)-Z(3) obj(5)-Z(6) obj(6)-Z(5)]./gui;        
    partd = [weight(1)*partc(1) weight(1)*partc(2) weight(2)*partc(3) weight(2)*partc(4) weight(3)*partc(5) weight(3)*partc(6)];
    oldobj1 = compare(partd(1:4),2);         
    oldobj = compare([oldobj1,partd(5:6)],2);
    
    compare1 = [newobj,oldobj];
    result = compare(compare1,1);
    if result == newobj
        chrom=newpoint;
        obj=Z_new;
    end
    
end
end

